import React from 'react'
import Link from 'umi/link';
import {Card} from 'antd'
import PageHeader from './PageHeader'
import MenuContext from '../BasicLayout/MenuContext'

export default ({ className, children, isCard = true, ...restProps }) => (
  <div style={{ margin: '-24px -24px 0' }} className={className}>
    <MenuContext.Consumer>
      {value => (
        <PageHeader
          {...value}
          key="pageheader"
          {...restProps}
          linkElement={Link}
          itemRender={item => item.name}
        />
      )}
    </MenuContext.Consumer>
    {isCard ?
      <Card style={{margin: 24}}>
        {children}
      </Card> :
      children
    }
  </div>
)
